package com.faithbj.common.dao.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.faithbj.common.dao.UserDao;
import com.faithbj.common.model.User;

/**
 * @author jrn E-mail: rinanjin@gmail.com
 * @version 0.1 创建时间：2012-6-4 下午09:24:01 类说明
 */
@Repository("userDao")
public class UserDaoImpl extends BaseDaoImpl<User, String> implements UserDao
{
	@Override
	public User getUserByUsername(String username)
	{
		Session session = this.getSession();
		Criteria criteria = session.createCriteria(User.class);
		criteria.add(Restrictions.eq("username", username));
		@SuppressWarnings("unchecked")
		List<User> list = criteria.list();
		if (list.size() > 0)
		{
			return list.get(0);
		}
		return null;
	}
}
